//
//  GroundViewController.m
//  NewProject
//
//  Created by Livespro on 2016/11/26.
//  Copyright © 2016年 FZ. All rights reserved.
//

#import "GroundViewController.h"

//#import "HXLoginViewController.h"
//#import "HXMainViewController.h"

#define ChatListArray @[@"环信"]

@interface GroundViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong)  UITableView *chatList;

@end

@implementation GroundViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

- (void)staticViewsWithoutNib{
    
    [self.view addSubview:self.chatList];
    
}

#pragma mark - lazyLoad

-(UITableView *)chatList{
    if (!_chatList) {
        _chatList=[[UITableView alloc]initWithFrame:CGRectMake(0, 64, kScreenWidth, kScreenHeight - 64 - 49) style:UITableViewStyleGrouped];
        
        _chatList.delegate = self;
        _chatList.dataSource = self;
        _chatList.showsHorizontalScrollIndicator = NO;
        _chatList.showsVerticalScrollIndicator  = NO;
        _chatList.separatorStyle = UITableViewCellSeparatorStyleNone;
        _chatList.backgroundColor=pageColor;
        
    }
    return _chatList;
}

#pragma mark - TableViewDataSource

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
   return ChatListArray.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;{
    
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;{
    
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([self class])];
    
    if (!cell)
    {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:NSStringFromClass([self class])];
        
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        
        cell.textLabel.font = [UIFont systemFontOfSize:14];
        cell.detailTextLabel.font = [UIFont systemFontOfSize:12];
        cell.textLabel.textColor = [UIColor colorWithHexString:@"333333"];
        cell.detailTextLabel.textColor = [UIColor colorWithHexString:@"999999"];
        cell.imageView.frame = CGRectMake(10, 12, 20, 20);
    }
    
    cell.textLabel.text = ChatListArray[indexPath.row];
    cell.detailTextLabel.text = [NSString stringWithFormat:@"%@让通讯更加简单",ChatListArray[indexPath.row]];
    cell.imageView.image = [UIImage imageNamed:ChatListArray[indexPath.row]];

    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    NSString *name_Stand = ChatListArray[indexPath.row];
    
    if ([name_Stand isEqualToString:@"环信"]) {
        
//        BOOL isAutoLogin = [EMClient sharedClient].options.isAutoLogin;
//
//        if (isAutoLogin && HXChatIsLogin) {
//
//            [self HXLoginJumpAction];
//
//        } else {
//
//            [self chatLoginAction];
//
//        }
        
    } else {
        
    }
   
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    return 10;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    
    return 0.01f;
}

#pragma mark - 登录操作
- (void)chatLoginAction{
    
//    HXLoginViewController *HXLogin = [[HXLoginViewController alloc]init];
//
//    __weak typeof(self) weakSelf = self;
//    HXLogin.loginSuccess = ^(){
//
//        [weakSelf HXLoginJumpAction];
//    };
//
//    [self presentViewController:HXLogin animated:YES completion:nil];
//
}

#pragma mark - 环信登录跳转
- (void)HXLoginJumpAction{
//
//    HXMainViewController *HXMain = [[HXMainViewController alloc]init];
//
//    [self.navigationController pushViewController:HXMain animated:YES];
//
}


@end
